package com.xxx.shetuan3.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxx.shetuan3.dao.NoticeDao;
import com.xxx.shetuan3.exception.ApiException;
import com.xxx.shetuan3.pojo.Notice;
import com.xxx.shetuan3.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeDao noticeDao;
    @Override
    public boolean saveNotice(Notice notice) {
        return noticeDao.saveNotice(notice)==1?true:false;
    }

    @Override
    public boolean deleteNoticeById(Integer noticeId) {
        return noticeDao.deleteNoticeById(noticeId)==1?true:false;
    }

    @Override
    public boolean updateNotice(Notice notice) {
        return noticeDao.updateNotice(notice)==1?true:false;
    }

    @Override
    public Notice queryNoticeById(Integer noticeId) {
        return noticeDao.queryNoticeById(noticeId);
    }

    @Override
    public List<Notice> queryNoticePageByOrganizationId(Integer start,Integer size,Integer organizationId) {
        PageHelper.startPage(start,size);
        List<Notice> noticeList = noticeDao.queryNoticeByOrganizationId(organizationId);
        PageInfo<Notice> noticePageInfo = new PageInfo<>(noticeList);
        return noticePageInfo.getList();
    }
}
